package demo31;

import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sr=new Scanner(System.in);
        LinkedList<Integer> a=new LinkedList<>();
        int n=sr.nextInt();
        int t;
        for (int i = 0; i < n; i++) {
            t=sr.nextInt();
            System.out.println(t);
            a.push(t);
        }
        System.out.println(a.get(0)+","+a.isEmpty()+","+a.size());
        tosc(a);
        int n2=sr.nextInt();
        if (n2<=a.size()) {
            for (int i = 0; i <n2; i++) {
                System.out.println(a.pop());
            }
        }else {
            System.out.println(a.size());
            for (int i = 0; i <a.size(); i++) {
                System.out.println(a.pop());
            }
            for (int i = a.size(); i < n2; i++) {
                System.out.println("null");
            }
        }
        System.out.println(a.get(0)+","+a.isEmpty()+","+a.size());
        tosc(a);
    }
    public static void tosc(LinkedList<Integer> a){
        if (!a.isEmpty()) {
            System.out.print("[");
            for (int i = a.size()-1; i>=0; i--) {
                System.out.print(i==0?a.get(i):a.get(i)+", ");
            }
            System.out.println("]");
            return;
        }
        System.out.println("null");
    }
}
